package com.yly.doctorapp.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yly.doctorapp.R;
import com.yly.doctorapp.bean.ProductionBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ProductionAdapter extends BaseAdapter {
    private Context mContext;
    private List<ProductionBean> productionBeanList;

    public ProductionAdapter(Context mContext, List<ProductionBean> productionBeanList) {
        this.mContext = mContext;
        this.productionBeanList = productionBeanList;
    }

    @Override
    public int getCount() {
        return productionBeanList.size();
    }

    @Override
    public Object getItem(int position) {
        return productionBeanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = null;
        if (convertView == null) {
            view = View.inflate(mContext, R.layout.layout_productionitem, null);
        } else {
            view = convertView;
        }
        if (null != productionBeanList && productionBeanList.size() > 0){
            ViewHolder holder = new ViewHolder(view);
            holder.tvProduction.setText(productionBeanList.get(position).getName());
        }
        return view;
    }

    static class ViewHolder {
        @BindView(R.id.tv_production)
        TextView tvProduction;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
